﻿<template>
  <div class="wrapper">
    <!-- 面包屑导航栏区域 -->
    <el-breadcrumb separator="/">
      <el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>销售管理</el-breadcrumb-item>
      <el-breadcrumb-item>添加销售单</el-breadcrumb-item>
    </el-breadcrumb>
    <el-card class="body">
      <!-- 添加表单 -->
      <div slot="header" class="clearfix">
        <span>添加销售单</span>
      </div>
      <el-form :inline='true' label-position='top' ref="form" :model="addForm" label-width="100px">
        <el-form-item label="销售单号" > 
          <el-input v-model="addForm.id" style="width:300px;"></el-input>
        </el-form-item>
        <el-form-item label="销售时间" > 
          <el-date-picker v-model="addForm.time" type="datetime" placeholder="选择日期时间" 
          align="right" :picker-options="pickerOptions"
          format="yyyy-MM-dd hh:mm"></el-date-picker>
        </el-form-item>
        <el-form-item label="药品总价格" > 
          <el-input v-model="addForm.price" style="width:500px;"></el-input>
        </el-form-item><br>
        <el-form-item label="销售负责人">
          <el-select style="width:500px;" v-model="addForm.emp"  size="normal"  placeholder="请选择">
                <el-option
                  v-for="item in options"
                  :key="item.id"
                  :label="item.empName"
                  :value="item.empName">
                </el-option>
              </el-select>
        </el-form-item><br>
        <el-form-item label="备注" > 
          <el-input v-model="addForm.remarks" type="textarea" style="width:650px;" placeholder="备注"></el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" style="width:650px" @click="onSubmit">添加</el-button>
        </el-form-item>
      </el-form>
    </el-card>
  </div>
</template>

<script>
import axios from 'axios'; 
export default {
  components: {},
  props: {},
  data() {
    return {
      options: [],
        value:'',
      addForm: {
          name: '',
          age: '',
          phone: '',
          sex: 1,
          address: '',
          position: '',
          emp:'',
          time:''
        },
        // 时间选择器
        pickerOptions: {
          shortcuts: [{
            text: '今天',
            onClick(picker) {
              picker.$emit('pick', new Date());
            }
          }, {
            text: '昨天',
            onClick(picker) {
              const date = new Date();
              date.setTime(date.getTime() - 3600 * 1000 * 24);
              picker.$emit('pick', date);
            }
          }, {
            text: '一周前',
            onClick(picker) {
              const date = new Date();
              date.setTime(date.getTime() - 3600 * 1000 * 24 * 7);
              picker.$emit('pick', date);
            }
          }]
        },
        //初始化负责人
        employeeInit(){
           axios({
              url:'http://162.14.65.162:9090/myblog/employee/list',   
               method:'get'}).then((res)=>{
                    //请求成功的时候执行
                    console.log('后端响应回来的内容',res);
                    //判断后端返回来的内容是成功的还是失败的
                    if(res.data.code === 200){
                        //服务器操作成功
                        this.options=res.data.data;
                       
                    }else{
                        //服务器操作失败
                        alert('服务器报错 请稍后重试')
                    }
                }).catch(function(err){
                    //请求失败的时候执行
                    console.log('请求失败的原因：',err);
                })
        }
    };
  },
  watch: {},
  
  computed: {},
  methods: {
    onSubmit(){
      let {emp,time} = this.addForm;
      console.log(emp,time)
    },
  },
  created() {},
  mounted() {
    this.employeeInit();
  }
};
</script>
<style lang="less" scoped>

.body{
  width: 800px;


}
</style>